package com.llc.mall.auth;

import io.seata.spring.boot.autoconfigure.SeataAutoConfiguration;
import io.seata.spring.boot.autoconfigure.SeataDataSourceAutoConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationListener;

@SpringBootApplication(
        scanBasePackages = {"com.mall4j.cloud", "com.llc.mall"},
        exclude = {
                SeataAutoConfiguration.class,
                SeataDataSourceAutoConfiguration.class
        }
)
@EnableFeignClients(basePackages = {"com.mall4j.cloud.api.**.feign"})
public class AuthApplication {

    private static final Logger log = LoggerFactory.getLogger(AuthApplication.class);

    private static volatile long startTime;

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(AuthApplication.class);
        // 添加启动开始事件监听
        app.addListeners((ApplicationListener<ApplicationStartingEvent>) event ->
                startTime = System.currentTimeMillis()
        );
        // 添加启动完成事件监听
        app.addListeners((ApplicationListener<ApplicationReadyEvent>) event -> {
            long cost = System.currentTimeMillis() - startTime;
            log.info("======> Auth服务启动完成, 耗时: {} ms <====== ", cost);
        });
        app.run(args);
    }
}

